<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var objs = document.getElementsByName("id");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].checked){
				sign = sign + 1;
			}
		}
		if(sign <= 0){
			alert("请选择要恢复的项！");
			return false;
		}
		return true;
	}

	function nowBackup(){
		document.backupManageForm.action = "./backupManage.do?action=nowBackup";
		document.backupManageForm.target = "main";
		document.backupManageForm.submit();
		document.getElementById("backup").href = "#";
		document.getElementById("trImport").style.display = "block";
		document.getElementById("tableImportInfo").style.display = "none";
		document.getElementById("tableImportInfo2").style.display = "none";
	}

	function autoBackup(){
		document.backupManageForm.action = "./backupManage.do?action=preAutoBackup";
		document.backupManageForm.target = "main";
		document.backupManageForm.submit();
	}
	
	function dataRestore(){
		if(checkForm()){
			document.backupManageForm.action = "./backupManage.do?action=restoreData";
			document.backupManageForm.target = "main";
			document.backupManageForm.submit();
			document.getElementById("restore").href = "#";
			document.getElementById("trImport").style.display = "block";
			document.getElementById("tableImportInfo").style.display = "none";
			document.getElementById("tableImportInfo2").style.display = "none";
		}
	}
	
	function pageCustomer(flag){
		document.backupManageForm.action = "./backupManage.do?action=display&flag="+flag;
		document.backupManageForm.target = "main";
		document.backupManageForm.submit();
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			var backupPath = document.getElementById("backupPath");
			alert("备份成功！备份文件存放路径：" + backupPath.value);
		}else if("<c:out value='${result}'/>" == 2){
			alert("恢复数据成功！");
		}
		
		document.getElementById("backup").href = "javascript:nowBackup();";
		document.getElementById("restore").href = "javascript:dataRestore();";
		document.getElementById("trImport").style.display = "none";
		document.getElementById("tableImportInfo").style.display = "block";
		document.getElementById("tableImportInfo2").style.display = "block";
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="backupManageForm" action="" method="post">
	<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" colspan="2">备份管理</td>
					</tr>
					<tr>
						<td valign="bottom" class="a_tools" style="padding-left: 3px;">
							<a name="backup" class="backup" href="javascript:nowBackup();" title="立即备份" hidefocus="true">立即备份</a>
							<a href="javascript:autoBackup();" title="自动备份设置" hidefocus="true">自动备份</a>&nbsp;&nbsp;
							<a id="restore" name="restore" class="restore" href="javascript:dataRestore();" title="数据恢复" hidefocus="true">数据恢复</a>
						</td>
						<td></td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">
							备份文件列表
						</td>
					</tr>
					<tr id="trImport" style="display: none;">
						<td class="" style="height: 50px;text-align: center;">
							<input id="backupPath" name="backupPath" type="hidden" value="${backupPath}"/>
							<b>正在执行信息，请稍后......</b>
						</td>
					</tr>
					<tr>
						<td>
							<table class="table">
								<tr>
									<td valign="top">
										<table id="tableImportInfo" class="table_style">
											<tr>
												<td class="title" width="8"></td>
												<td class="title" width="30">选择</td>
												<td class="title" width="">文件名称</td>
												<td class="title" width="">备份时间</td>
												<td class="title" width="">备份方式</td>
											</tr>
											<c:forEach var="backupData" items="${backupDatas}" varStatus="b">
											<tr onmouseover="onmousemoveChange(this,'img${b.count}')" onmouseout="onmouseoutChange(this,'img${b.count}')">
												<td height="16" width="8" align="right"><img id="img${b.count}" src="./images/table_sign2.bmp"></td>
												<td><input id="id" name="id" type="radio" value="${backupData.path}"/></td>
												<td>${backupData.backupName}</td>
												<td><fmt:formatDate value="${backupData.backupDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
												<td>
												<c:choose>
													<c:when test="${backupData.backupWay == '1'}">手动</c:when>
													<c:when test="${backupData.backupWay == '2'}">自动</c:when>
												</c:choose>
												</td>
											</tr>
											</c:forEach>
										</table>
									</td>
								</tr>
								<tr>
									<td>
										<!-- page -->
										<table id="tableImportInfo2" class="table_page">
											<tr>
												<td class="a_tools">
													${fn:length(backupDatas)}&nbsp;<fmt:message key='common.page.totalRow'/>&nbsp;&nbsp;
													<fmt:message key='common.page.totalPage'/>&nbsp;${countPage}&nbsp;<fmt:message key='common.page'/>&nbsp;&nbsp;
													<fmt:message key='common.page.current'/>&nbsp;${currentPage}&nbsp;<fmt:message key='common.page'/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													<a href="javascript:pageCustomer(1);" target="main" hidefocus="true"><fmt:message key='common.page.first'/></a>&nbsp;&nbsp;
													<a href="javascript:pageCustomer(2);" target="main" hidefocus="true"><fmt:message key='common.page.previous'/></a>&nbsp;&nbsp;
													<a href="javascript:pageCustomer(3);" target="main" hidefocus="true"><fmt:message key='common.page.next'/></a>&nbsp;&nbsp;
													<a href="javascript:pageCustomer(4);" target="main" hidefocus="true"><fmt:message key='common.page.last'/></a>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
</body>
</html>